<template>
  <el-container class="app-container">
    <el-header class="app-header" v-if="showHeader">
      <div class="header-left">
        <div class="logo-area">
          <el-icon :size="24" class="logo-icon"><DataAnalysis /></el-icon>
          <span class="app-title">数据分析系统</span>
        </div>
        
        <!-- 顶部导航菜单 -->
        <el-menu
          :default-active="activeMenu"
          mode="horizontal"
          :ellipsis="false"
          router
          class="horizontal-menu"
        >
          <el-menu-item index="/cases">
            <el-icon><Folder /></el-icon>
            <span>案件管理</span>
          </el-menu-item>
          <el-menu-item index="/templates">
            <el-icon><Document /></el-icon>
            <span>模板管理</span>
          </el-menu-item>
          <el-sub-menu index="basic">
            <template #title>
              <el-icon><Setting /></el-icon>
              <span>系统设置</span>
            </template>
            <el-menu-item index="/settings/storage">存储管理</el-menu-item>
            <el-menu-item index="/settings/logs">系统日志</el-menu-item>
            <el-menu-item index="/settings/schema">系统表</el-menu-item>
          </el-sub-menu>
        </el-menu>
      </div>
      <div class="header-right">
        <!-- Future: User profile or settings -->
      </div>
    </el-header>
    
    <el-main class="app-main" :class="{ 'no-header': !showHeader }">
      <router-view v-slot="{ Component }">
        <transition name="fade" mode="out-in">
          <component :is="Component" />
        </transition>
      </router-view>
    </el-main>
  </el-container>
</template>

<script setup>
import { computed } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()
const activeMenu = computed(() => route.path)
const showHeader = computed(() => !route.path.startsWith('/workbench'))
</script>

<style>
:root {
  --el-color-primary: #409eff;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: #f5f7fa;
}

.app-container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  background-color: #fff;
  border-bottom: 1px solid #dcdfe6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 60px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 30px;
  flex: 1;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 600;
  color: var(--el-color-primary);
}

.horizontal-menu {
  border-bottom: none;
  flex: 1;
}

.app-main {
  padding: 0;
  background-color: #f0f2f5;
  overflow: hidden;
  flex: 1;
}

.app-main.no-header {
  padding: 0; /* Workbench handles its own padding/layout */
}

.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.2s ease;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style>
